﻿		<p class="right"><a href="{url_to controller="admin" action="user" params=[$cli_id]}">Retour</a></p>
		<br/>
		<table id="account_details">
			<tr>
				<td class="border"><label>Type de compte:</label>{$entitled}</td>
				<td class="border">
					<label>Dépôt maximum:</label>{$ceiling}<br/>
					<label>Découvert autorisé:</label>{$overdraft}
				</td>
			</tr>
			<tr>
				<td class="border"><label>Date de création:</label>{$creation_date}</td>
				<td class="border"><label>Solde:</label>{$amount}</td>
			</tr>
			<tr>
				<td colspan="2" class="border">
					<div id="center_div">
						<table id="trs_list_tbl"></table>
						<div id="pager"></div>
					</div> 
					<script>
					{literal}
						$(function(){ 
						  	$("#trs_list_tbl").jqGrid({
							    url:'{/literal}{url_to controller="admin" action="account" params=[$id]}{literal}',
								datatype: 'json',
								mtype: 'POST',
							    colNames:['Date','Intitulé', 'Montant'],
							    colModel :[ 
							    	{name:'date', index:'date', width:200}, 
							    	{name:'entitled', index:'entitled', width:200}, 
							    	{name:'amount', index:'amount', width:200, align:'right'}, 
						    	],
						    	pager: '#pager',
								rowNum: 10,
								rowList: [10,20,30],
							    sortname: 'Date',
							    sortorder: 'desc',
							    viewrecords: true,
							    gridview: true,
							    caption: 'Transactions sur le compte',
							    height: 220,
							    hidegrid: false
						  	});
						}); 
					{/literal}
					</script>
				</td>
			</tr>
			<tr>
				<td class="border center" colspan="2">
					<button id="remove_account">Supprimer le compte</button>
				</td>
			</tr>
		</table>
		<div id="remove_account_form" title="Supprimer le client">
			<form>
				<fieldset>
					<label for="secure">Etes vous sûr ?</label><input type="checkbox" name="secure" id="secure"/><br/>
					<label for="password">Mot de passe administrateur :</label><input type="password" name="password" id="password" class="text ui-widget-content ui-corner-all"/>
				</fieldset><br/>
			</form>
			<p class="validateTips"></p>
		</div>
		<script>
		{literal}
			$(function(){
				
				var secure = $( "#secure" ),
					password = $( "#password" ),
					allFields = $( [] ).add( secure ).add( password ),
					tips = $( "#remove_account_form .validateTips" ) ;
				
				function updateTips( t ) {
					tips
						.text( t )
						.addClass( "ui-state-highlight" );
					setTimeout(function() {
						tips.removeClass( "ui-state-highlight", 1500 );
					}, 500 );
				}
		
				function checkRegexp( o, regexp, n ) {
					if ( !( regexp.test( o.val() ) ) ) {
						o.addClass( "ui-state-error" );
						updateTips( n );
						return false;
					} else {
						return true;
					}
				}
				
				$("#remove_account")
					.button()
					.click(function(){
						$( "#remove_account_form" ).dialog ( "open" ) ;
					});
				
				$( "#remove_account_form" ).dialog({
					autoOpen: false,
					height: 500,
					width: 550,
					modal: true,
					buttons: {
						"Envoyer": function() {
							var bValid = true;
							allFields.removeClass( "ui-state-error" );
							
							bValid = bValid && secure.attr('checked') == 'checked' ;
		
							if ( bValid ) {
								// Si les champs sont valides, faire une requête Ajax pour tenter de connecter l'utilisateur
								
								allFields.removeClass( "ui-state-error" );
								tips.text( "" );
								
								$.post( "{/literal}{url_to controller="admin" action="account"}{literal}",
									{
										rm_account_form: 0,
										pass: password.val(),
										id: {/literal}{$id}{literal}
									},
										function(data){
											updateTips( data[1] ) ;
											
											if ( data[0] == 1 )
												setTimeout( function() {
														$( location ).attr( "href", "{/literal}{url_to controller="admin" action="user" params=[$cli_id]}{literal}" );
													},
													1000 );
										},
										"json");
								
							}
							
						},
						"Reset": function() {
							allFields.val( "" ).removeClass( "ui-state-error" );
							tips.text( "" );
						},
						"Annuler": function() {
							$( this ).dialog( "close" );
						}
					},
					close: function() {
						allFields.val( "" ).removeClass( "ui-state-error" );
						tips.text( "" );
					},
					open: function() {
						
					}
				});
				
			});
		{/literal}
		</script>